import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/3/31 9:39
 * 微信红包
 *  计算字符串的编辑距离
 */
public class Day23 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String s1 = s.nextLine();
        String s2 = s.nextLine();
        System.out.println(stringDistance(s1, s2));
    }
    //--------------------------------------
    public static int stringDistance(String str1,String str2){
       int[][] dp = new int[str1.length()+1][str2.length()+1];
       dp[0][0] = 0;
        for (int i = 1; i < str1.length()+1; i++) {
            dp[i][0] = i;
        }
        for (int i = 1; i < str2.length()+1; i++) {
            dp[0][i] = i;
        }
        for (int i = 1; i < str1.length()+1; i++) {
            for (int j = 1; j < str2.length()+1; j++) {
                if (str1.charAt(i-1)==str2.charAt(j-1)){//==
                    dp[i][j] = dp[i-1][j-1];
                }else {//add del exchange
                    dp[i][j] = Math.min(dp[i-1][j]+1,Math.min(dp[i][j-1]+1,dp[i-1][j-1]+1));
                }
            }
        }
        return dp[str1.length()][str2.length()];
    }
    //--------------------------------------
    public int getValue(int[] gifts, int n) {
        // write code here
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (!map.containsKey(gifts[i])){
                map.put(gifts[i],1);
            }else {
                map.put(gifts[i],map.get(gifts[i])+1);
            }
        }
        for(Map.Entry<Integer,Integer> en : map.entrySet()){
            if (en.getValue() > n/2){
                return en.getKey();
            }
        }
        return 0;
    }
}
